#include <stdio.h>
#include <unistd.h>
#include <wait.h>
#include <string.h>


int main(int argc, const char *argv[])
{
	int fd1[2];
	pipe(fd1);

	pid_t pid = fork();

	if(pid==0)
	{
		char writebuf[32]={0};
		close(fd1[0]);
		while(1)
		{
			scanf("%s",writebuf);
			write(fd1[1],writebuf,strlen(writebuf));
			memset(writebuf,0,32);
		}

	}
	else if(pid>0)
	{
		char readbuf[32]={0};
		close(fd1[1]);
		while(1)
		{
			read(fd1[0],readbuf,32);
			printf("recvzi: %s\n",readbuf);
			memset(readbuf,0,32);
		}

		wait(NULL);
	}




	return 0;
}
